import request from "@/request/request";
import { getToken, getRefreshToken } from '@/request/auth'

// 登录并获得token
export function login(data) {
    return request.post("/token", data);
}
export function Register(data){
    return request.post("/addUser",data)
}

// 不登录的情况下刷新token
export function refreshToken() {
    let accessToken = getToken();
    let refreshToken = getRefreshToken();
    let data = {
        accessToken,
        refreshToken
    }
    if (accessToken && refreshToken) {
        return request.post("/refreshtoken", data);
    } else {
        return false;
    }
}